<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('订单明细')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
    <div class="main-content">
        <form id="form-add" name="myForm" class="form-horizontal" th:object="${goodsOrder}">
            <input name="deptId" type="hidden" id="treeId"/>
            <input name="deptAddress" type="hidden" id="deptAddress" th:value="${deptAddress}"/>

            <h4 class="form-header h4">订单信息</h4>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">订单号：</label>
                        <div class="col-sm-8">
                            <input id="orderNo" readonly placeholder="请输入客户名称" class="form-control" type="text" maxlength="30" th:value="${orderNo}">
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">订单状态：</label>
                        <div class="col-sm-8">
                            <select name="status" id="status" class="form-control" th:with="type=${@dict.getType('order_status')}" readonly>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{status}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label is-required">订单金额：</label>
                        <div class="col-sm-8">
                            <input name="orderMoney" readonly class="form-control" type="text" maxlength="30" th:value="${goodsOrder.orderMoney}" >
                        </div>
                    </div>
                </div>
                <div class="col-sm-6">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">支付方式：</label>
                        <div class="col-sm-8">

                            <select name="payChannelId" id="payChannelId" class="form-control" th:with="type=${@dict.getType('pay_channel')}">
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{payChannelId}"></option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <ul class="sortable-list connectList agile-list">
                <li class="warning-element">
                    <div class="col-sm-offset-5 col-sm-10">
                        <span th:if="${goodsOrder.status eq 2}">
                            <!-- 支付成功 -->
                            <img id="imgSuccess"  src='../static/paySuccess.png' th:src="@{/paySuccess.png}" height="48px">
                            <!--<button type="button" class="btn btn-primary" onclick="printOrder()"><i class="fa fa-check"></i> 打印小票</button>-->

                        </span>
                        <span th:if="${goodsOrder.status ne 2}">
                            <button type="button" class="btn btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i> 收 款</button>&nbsp;&nbsp;&nbsp;
                        </span>
                        <button type="button" class="btn btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
                    </div>                    &nbsp;&nbsp;
                </li>
            </ul>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/static/js/jquery.tmpl.js}"></script>
    <script language="JavaScript">
        function  submitHandler() {
            $.modal.confirm("确认已收到客人钱",function (){
                var orderNo=$("#orderNo").val();
                var payChannelId=$("#payChannelId").find("option:selected").val();
                $.operate.saveModal(ctx + "goods/order/paySuccess", {orderNo:orderNo,payChannelId:payChannelId},function (a,b){
                    console.log("11111111111111111"+a.code)
                    if(a.code==0){
                        window.open(ctx+"goods/order/orderPrint/"+$("#orderNo").val());

                        setTimeout(function (){
                            location.reload();
                        },2000);

                        // $.ajax({
                        //     type: "post",
                        //     url: ctx + "goods/orderHead/list/",
                        //     data: {
                        //         "orderNo": orderNo
                        //     },
                        //     success: function(data) {
                        //        // console.log(data.rows)
                        //         /*alert(JSON.stringify(data.rows))*/
                        //         //console.log(JSON.stringify(data.rows));
                        //         //alert(JSON.stringify(data.rows));
                        //         //window.external.appPrint(orderNo,JSON.stringify(data.rows),$("#deptAddress").val());
                        //     }
                        // });
                    }
                });
            });
        }
        
        function printOrder() {
            window.open(ctx+"goods/order/orderPrint/"+$("#orderNo").val());
        }
    </script>
</body>
</html>